<meta title="淘宝物料选择器" width="500"/>
<div class="p">
    <select class="form-control" s="select"
            name="materialId"
            id="materialId"
            s-build="materialList()">
        <option value="">默认物料</option>
    </select>
</div>
<script type="text/javascript">
    function materialList() {
        var deferred = $.Deferred();
        S.get("/api/setting/TaobaoMaterialSetting").done(function(setting) {
            deferred.resolve(setting.materialList.map(function (m) {
                m.name = '[' + m.id + ']' + m.name
                return m
            }))
        })
        return deferred;
    }
    S.meta.btns = [
        {
            name: "选择",
            style: "btn btn-primary",
            click: function() {
                S.close($materialId.node.val())
            }
        },
        {
            name: "关闭",
            style: "btn btn-default",
            click: function() {
                S.close();
            }
        }
    ]
</script>